package com.laborer.PTSS.web.servlet;

import com.laborer.PTSS.domain.Course;
import com.laborer.PTSS.service.SearchService;
import com.laborer.PTSS.service.impl.SearchServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/search/*")
public class SearchServlet extends BaseServlet {
    // 声明一个SearchService的业务对象
    private SearchService service = new SearchServiceImpl();

    public void getSearchResult(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        String cid = request.getParameter("cid");
        String rname = request.getParameter("rname");
        System.out.println(cid);
        System.out.println(rname);
        List<Course> courseList = service.getCourseListBySearch(rname);
        System.out.println(courseList);
        writeValue(courseList, response);
    }
}
